package my.jwds.p357;

public class CountNumbersWithUniqueDigits {

    public static void main(String[] args) {

        Solution obj = new Solution();
        long start = System.currentTimeMillis();
        System.out.println(obj.countNumbersWithUniqueDigits(3));
        System.out.println("运行时间:" + (System.currentTimeMillis() - start));
    }

    static class Solution {

        public int countNumbersWithUniqueDigits(int n) {
            if (n == 0)return 1;
            if (n == 1)return 10;
            int res = 10,now = 9;

            for (int i = 0; i <= n-2; i++) {
                now *= (9-i);
                res += now;
            }
            return res;
        }

    }
}